/**
 * 项目对应的service
 */
define(function (require) {
    'use strict';
    var angular = require('angular');
    var _ = require('underscore');

    angular.module('teamServiceApp',[])
        .factory('teamService',['$http',function($http){
            function httpGet(url,data){
                url = '/api/index.php?r=' + url ;
                return $http.get(url,{params:data});
            }
            return {
                getTeamList : function (scope) {
                    var url = 'salesuser/sales-team/list';
                    var data = {
                        proj_id : scope.curProjectId
                    };
                    httpGet(url,data).then(function (res) {

                        scope.teamDatas = res.data.data.teams;

                        scope.teamList = _.map(scope.teamDatas || [], function (item) {
                            item.text = item.team_name;
                            return item;
                        });
                    });
                }
            };
        }]);
});
